<template>
  <!--资讯发布新增/编辑弹窗-->
  <a-modal  :maskClosable="false"
            :title="mdl.dialogTitleMap[mdl.dialogStatus]"
            :width="1000"
            @ok="mdl.dialogStatus === 'create' ? createData() : updateData()"
            v-model="mdl.visible"
  >
    <a-form>
      <a-form-item
        :labelCol="mdl.labelCol"
        :wrapperCol="mdl.wrapperCol"
        label="资讯名称"
      >
        <a-input placeholder="" v-model="mdl.formData.bt"/>
      </a-form-item>
      <a-form-item
        :labelCol="mdl.labelCol"
        :wrapperCol="mdl.wrapperCol"
        label="资讯内容"
      >
        <a-textarea :rows="4" v-model="mdl.formData.nr"/>
      </a-form-item>
    </a-form>
  </a-modal>
</template>
<script>
/* eslint-disable */
import {insertInfoContentE,editInfoContentE} from '@/api/messageManage/newsDissemination'

  export default {
    components: {

    },
    props: {
      /*   -------弹窗--------*/
      mdl: {
        dialogStatus: '',
        dialogTitleMap: {
          update: '编辑',
          create: '新增'
        },
        visible: false,
        title: '',
        formData: {
          bt: '',
          cjsj: '',
          dwdxid: '',
          dxid: '',
          fbr: '',
          gxsj: '',
          lxdxid: '',
          ly: '',
          nr: '',
          sh: '',
          tp: '',
          xwfbsj: ''
        },
        labelCol: {
          xs: {
            span: 24
          }
          ,
          sm: {
            span: 5
          }
        }
        ,
        wrapperCol: {
          xs: {
            span: 24
          }
          ,
          sm: {
            span: 16
          }
        },
      },
    },
    data() {
      return {
        index:0
      }
    },
    inject: ['upShow'],

    created() {

    },
    watch: {

    },
    computed: {

    },
    methods: {
      handleChange(value) {
        console.log(`Selected: ${value}`);
      },
      popupScroll() {
        console.log('popupScroll');
      },
      /**
       * 新增数据 insertInfoContentE
       * */
      createData() {
        console.log(this.mdl.formData);
        let parameter = this.mdl.formData;
        insertInfoContentE(parameter).then(res => {
          if(res.code === 200) {
            this.loading = false
            this.upShow(1,"新增成功")
            this.mdl.visible = false
            this.$emit("handleSearch");
          } else {
            this.loading = false
            this.upShow(2,res.msg)
          }
        }).catch(err => {
          this.loading = false
          console.log(err)
        })
      },
//      编辑
      updateData() {
        this.upShow(2,"修改数据")
        this.mdl.visible = false
        const parameter = {
          bt:this.mdl.formData.bt,
          createTime:this.mdl.formData.createTime,
          dwdxid:this.mdl.formData.dwdxid,
          dxid:this.mdl.formData.dxid,
          fbr:this.mdl.formData.fbr,
          gxsj:this.mdl.formData.gxsj,
          lxdxid:this.mdl.formData.lxdxid,
          ly:this.mdl.formData.ly,
          nr:this.mdl.formData.nr,
          sh:this.mdl.formData.sh,
          tp:this.mdl.formData.tp,
          xwfbsj:this.mdl.formData.xwfbsj
        }
        editInfoContentE(parameter).then(res => {
          if(res.code === 200){
            this.upShow(1,"修改成功")
            this.mdl.visible = false
            this.$emit("handleSearch");
          }
          else
          {
            this.upShow(2,res.msg)
          }

        }).
        catch(err => {
          this.upShow(2)
        })
      },
//      绑定警示教育
      onChange(checkedValues) {
        console.log('checked = ', checkedValues);
        console.log('value = ', this.mdl.formData.plainOptions);
      },
    }
  }
</script>